package study.member.sungil.datatype;

/**
 * @author : hiyogils
 * @date : 2014. 11. 20.
 * @description : 1-10 의 최소 공배수 
 */
public class ArrayEx {
	public static void main(String[] args) {
		ArrayEx arr = new ArrayEx();
		int numArr[] = {1,2,3,4,5,6,7,8,9,10};
		int result = 0;
		for(int i=0;i<numArr.length-1;i++){
			if(i == 0){
				result = arr.lcd(numArr[i], numArr[i+1]);	
			}else{
				result = arr.lcd(result, numArr[i+1]);
			}
		}
		System.out.println(result);
		
	}
	
	public int lcd(int num1 , int num2){
		int N, M ;
		int i;
		int result = 0;
		if(num1 > num2){
			M = num1;
			N = num2;
		}else{
			M = num2;
			N = num1;
		}
		for(i = 1; i <= N; i++){
			if(((M * i) % N) == 0){
				result= M*i;
					break;
			}
		}
		return result;
	}
}
